# makefile for test of linear algebra components

# for laptop
PETSC_DIR = /opt/petsc/petsc-3.1-p3
# for bert
#PETSC_DIR = /opt/petsc-3.1-p6
include ${PETSC_DIR}/conf/variables
include ${PETSC_DIR}/conf/rules
SERMENT = /home/robertsj/workspaceTMP/serment
LINALG = ${SERMENT}/linalg
DIFF2D = ${SERMENT}/diff2d


define two-lines
echo SERMENT
echo $(bar)
endef

# THIS IS AN EXTREMELY UGLY WAY TO LINK FROM MULTIPLE DIRECTORIES!!
# AT SOME POINT, I NEED TO MOVE TOWARD USING AUTOTOOLS!!
OBJSS1  =  testConnect2dCart.o ${SERMENT}/Connect2dCart.o ${LINALG}/SermentVector.o ${LINALG}/SermentMatrixFull.o ${LINALG}/SermentMatrixCRS.o
OBJSS2  =  testLegendrePoly.o ${DIFF2D}/LegendrePoly.o
OBJSS3  =  testResponseFunction.o ${SERMENT}/ResponseFunction.o ${SERMENT}/ResponseFunctionDiffusion.o
OBJSS4  =  testLocalProblemDiff2d.o ${SERMENT}/ResponseFunction.o ${SERMENT}/ResponseFunctionDiffusion.o ${SERMENT}/ResponseFunctionServer.o ${SERMENT}/ResponseMatrix.o ${SERMENT}/ResponseMatrixFull.o ${SERMENT}/LocalProblemDiff2d.o  ${SERMENT}/LeakageResponse.o ${SERMENT}/FissionResponse.o  ${SERMENT}/AbsorptionResponse.o ${DIFF2D}/Diff2dInput.o ${DIFF2D}/Diff2dProblem.o ${DIFF2D}/Diff2dSolver.o ${DIFF2D}/Diff2dOutput.o ${DIFF2D}/LegendrePoly.o  ${LINALG}/SermentVector.o ${LINALG}/SermentMatrixFull.o  ${LINALG}/SermentMatrixBCRS.o
CC      =  g++
DEBUG   = -g
CFLAGS  = -Wall $(DEBUG) -lstdc++ -I/opt/silo-4.7.2/include/ -I${SERMENT}/ -I${LINALG}/ -I${DIFF2D}/
LFLAGS  = -Wall $(DEBUG)
LIBRARY = -L/opt/silo-4.7.2/lib/ -lsilo -lm 

# PROGRAMS
all: testLegendrePoly # testResponseFunction testLocalProblemDiff2d testConnect2dCart 
testConnect2dCart: $(OBJSS1)  chkopts
	-${CLINKER} -o testConnect2dCart $(OBJSS1) ${PETSC_SYS_LIB} ${CFLAGS}
testLegendrePoly: $(OBJSS2)  chkopts
	-${CLINKER} -o testLegendrePoly $(OBJSS2) ${PETSC_SYS_LIB} ${CFLAGS} 
testResponseFunction: $(OBJSS3)  chkopts
	-${CLINKER} -o testResponseFunction $(OBJSS3) ${PETSC_SYS_LIB} ${CFLAGS}
testLocalProblemDiff2d: $(OBJSS4)  chkopts
	-${CLINKER} -o testLocalProblemDiff2d $(OBJSS4) ${PETSC_SYS_LIB} ${CFLAGS} ${LIBRARY}
# LINEAR ALGEBRA STUFF
SermentVector.o : ${LINALG}/SermentVector.cc
SermentMatrixFull.o : ${LINALG}/SermentMatrixFull.cc
SermentMatrixCRS.o : ${LINALG}/SermentMatrixCRS.cc
SermentMatrixBCRS.o : ${LINALG}/SermentMatrixBCRS.cc
# DIFF2D STUFF
Diff2dInput.o : ${DIFF2D}/Diff2dInput.cc
Diff2dProblem.o : ${DIFF2D}/Diff2dProblem.cc
Diff2dSolver.o : ${DIFF2D}/Diff2dSolver.cc
LegendrePoly.o : ${DIFF2D}/LegendrePoly.cc
Diff2dOutput.o : ${DIFF2D}/Diff2dOutput.cc
# SERMENT STUFF
AbsorptionResponse.o : ${SERMENT}/AbsorptionResponse.cc
Connect2dCart.o : ${SERMENT}/Connect2dCart.cc
FissionResponse.o : ${SERMENT}/FissionResponse.cc
LeakageResponse.o : ${SERMENT}/LeakageResponse.cc
ResponseFunction.o : ${SERMENT}/ResponseFunction.cc
ResponseFunctionDiffusion.o : ${SERMENT}/ResponseFunctionDiffusion.cc
ResponseFunctionServer.o : ${SERMENT}/ResponseFunctionServer.cc
ResponseMatrix.o : ${SERMENT}/ResponseMatrix.cc
ResponseMatrixFull.o : ${SERMENT}/ResponseMatrixFull.cc
LocalProblemDiff2d.o : ${SERMENT}/LocalProblemDiff2d.cc
# TEST STUFF
testConnect2dCart.o : testConnect2dCart.cc
testLegendrePoly.o : testLegendrePoly.cc

klean::
	@-${RM} *.o ../linalg/*.o ../diff2d/*.o *.lo *~ ex[0-9] ex[0-9][0-9] ex[0-9]f ex[0-9][0-9]f \
	       ${CLEANFILES} ${TESTS} ex[0-9]f90 ex[0-9][0-9]f90 ex[0-9]c ex[0-9][0-9]c ex[0-9]d ex5d \
	       PI* *.ln l.outa* mputil.mp_* core core.* *.tmp *.map gmon.out \
	       trashz \#*\# *.mex* *.stolen *.trace Log.* joe jeff *.stolen \
	       output/*~ .mpirtmp mon.out *.aus *.mon.* __* p4pg ins10*.c \
	       ex[0-9].exe ex[0-9][0-9].exe ex[0-9]f.exe ex[0-9][0-9]f.exe \
	       *.ad.c *.ad.h ad_deriv.h .adic* *.cp_ *.cp__ *.c*.c pageform.txt \
               .adic* *.dep *.proj ctoatmp PETScArena* *.L *.anl main *.mod .mpi* \
	       *.class *.ouit *.ad.* g_* silly.cmp *.tmp.* *.ilk *.pdb *.inst.c *.rej *.gcda *.gcno
	@-${RM} -rf ${CLEANDIRS} AD_cache SunWS_cache


